package config

import (
	"github.com/spf13/viper"
	"log"
)

type AppConfig struct {
	Mysql
}

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}

var AppConf AppConfig

func Init() {
	viper.SetConfigFile("config/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		panic(err)
	} else {
		log.Println("动态配置读取成功:", AppConf)
	}

}
